using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Microsoft.ConnectionEngine.SampleDeploymentManager.WizardPages
{
    public /*abstract*/ partial class WizardPageBase : UserControl
    {
        private const string PROD_NAME = "productName";
        private const string APP_NAME = "applicationName";

        protected Dictionary<string, object> _parameters;

        public event ErrorEventHandler Error;
        public event EventHandler Complete;

        public WizardPageBase()
        {
            InitializeComponent();
        }

        public virtual void Activate(ref Dictionary<string, object> parameters)
        {
            _parameters = parameters;

            string productName = "";
            string applicationName = "";

            if (_parameters.ContainsKey(PROD_NAME))
            {
                productName = _parameters[PROD_NAME].ToString();
            }
            if (_parameters.ContainsKey(APP_NAME))
            {
                applicationName = _parameters[APP_NAME].ToString();
            }

            lblMessage1.Text = string.Format(lblMessage1.Text, productName, applicationName);
        }

        protected void OnError(string message)
        {
            if (Error != null)
            {
                Error(this, new ErrorEventArgs(message));
            }
        }

        protected void OnComplete()
        {
            if (Complete != null)
            {
                Complete(this, new EventArgs());
            }
        }
    }
}
